package semana1.estructurasDeControl.ej14;

import java.util.Random;

public class Ej14 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Random r = new Random();
		int n1 = r.nextInt(50) + 1;
		int n2 = r.nextInt(50) + 1;
		int n3 = r.nextInt(50) + 1;
		int n4 = r.nextInt(50) + 1;

		
		// n1 = 1; n2 = 2; n3 = 2; n4 = 3;
		
		System.out.println("Numeros aleatorios generados: [" + n1 + "; " + n2
				+ "; " + n3 + "; " + n4 + "]");

		// MAYOR
		if (n1 >= n2 && n1 >= n3 && n1 >= n4) {
			System.out.println("El mayor es: " + n1);
		} else {
			if (n2 >= n1 && n2 >= n3 && n2 >= n4) {
				System.out.println("El mayor es: " + n2);
			} else {
				if (n3 >= n1 && n3 >= n2 && n3 >= n4) {
					System.out.println("El mayor es: " + n3);
				} else {
					if (n4 >= n1 && n4 >= n2 && n4 >= n3) {
						System.out.println("El mayor es: " + n4);
					}
				}
			}
		}

		// MENOR
		if (n1 <= n2 && n1 <= n3 && n1 <= n4) {
			System.out.println("El menor es: " + n1);
		} else {
			if (n2 <= n1 && n2 <= n3 && n2 <= n4) {
				System.out.println("El menor es: " + n2);
			} else {
				if (n3 <= n1 && n3 <= n2 && n3 <= n4) {
					System.out.println("El menor es: " + n3);
				} else {
					if (n4 <= n1 && n4 <= n2 && n4 <= n3) {
						System.out.println("El menor es: " + n4);
					}
				}
			}
		}

	}

}
